
(function () {
    'use strict';

    angular.module('KingAdmin.pages.pdev.devctrl')
        .controller('DevctrlCtrl', DevctrlCtrl);

    /** @ngInject */
    function DevctrlCtrl($scope, $stateParams, $state,$uibModalInstance, DevctrlService, DictService, DeviceService) {
        var kt = this;
        kt.devctrl = {};
        kt.title = '编辑设备控制';

        if($stateParams.id){
            if ($stateParams.isView) {
                kt.isView = true;
                kt.title = '查看设备控制';
            }

            DevctrlService.getInfo({id:$stateParams.id},
                function (data) {
                kt.devctrl = data;
            })
        }else{
            kt.isAdd = true;
            kt.title = '添加设备控制';
            kt.devctrl = {
            };
        }

        kt.devList = DeviceService.getDevList();
        kt.devstatus = DictService.getDictMap('DEVICESTATUS');

        kt.save = function () {
            DevctrlService.save(kt.devctrl,function (data) {
                $uibModalInstance.close(true);
            });
        };

        $uibModalInstance.rendered.then(function() {

        });
    }

})();
